home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 755 < prev    next >
Internet Message Format  |  1996-08-06  |  2KB

  1. Path: inforamp.net!usenet
  2. From: pcurran@inforamp.net (Peter Curran)
  3. Newsgroups: comp.std.c
  4. Subject: Re: valueless return statement in non-void function
  5. Date: Wed, 17 Apr 1996 14:11:02 GMT
  6. Organization: PSC Enterprises
  7. Message-ID: <4l2u3t$io4@sam.inforamp.net>
  8. References: <829573502snz@wbriscoe.demon.co.uk> </REdxQ9ytt2Y089yn@csn.net>
  9. Reply-To: pcurran@inforamp.net
  10. NNTP-Posting-Host: ts34-09.tor.istar.ca
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. On 16 Apr 1996 21:41:21 -0600 in article </REdxQ9ytt2Y089yn@csn.net>
  14.     thads@csn.net (Thad Smith) (Thad Smith) wrote:
  15.  
  16. >In article <829573502snz@wbriscoe.demon.co.uk>,
  17. >walter briscoe <walter@wbriscoe.demon.co.uk> wrote:
  18. >>I recently had trouble moving some K&R code to ISO C.
  19. >>
  20. >>Specifically, a function without a return statement was used to return a
  21. >>value with an implicit return at the } terminating the function.
  22.  
  23. <snip>
  24.  
  25. >I haven't worked with much K&R code, so don't know how valid that is.
  26. >I suspect that there is lots of legacy code with an implicit int
  27. >return type that actually returns values.  My early impression of C
  28. >was that much code was designed to be parsimonious.
  29.  
  30. >The following proposal would be somewhat better: if the return type is
  31. >explicitly typed, the return statement must provide a value.
  32. >Someone will surely trot out some existing working code that violates
  33. >this, however.
  34.  
  35. >In the meantime, use a good lint.
  36.  
  37. Most modern compilers, as far as I have seen, provide a (suppressible) warning
  38. in this situation.  It could be viewed as a quality-of-implementation issue.
  39.  
  40. --
  41. Peter Curran                               pcurran@inforamp.net
  42.  
  43.